<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<f:view>
		<h:body>
			<ui:composition template="/template/template.xhtml">
				<ui:define name="conteudo">
					<rich:panel>
						<f:facet name="header">
							<h:outputText value="#{res.posto_Titulo_Cadastro}" />
						</f:facet>
						<h:form>
							<rich:messages />
							<h:panelGrid id="formGrid" columns="2">
								
								<h:outputLabel value="#{res.nome_distribuidor}"  for="noDistribuidor"/>
								<h:selectOneMenu value="#{postoBean.posto.distribuidor.idDistruibuidor}" id="noDistribuidor" label="#{res.nome_distribuidor}">
									<f:selectItem itemLabel="Selecione" itemValue="0"/>
									<f:selectItems value="#{postoBean.distribuidores}" />
								</h:selectOneMenu>
								
								<h:outputLabel value="#{res.nome_posto}"  for="noPosto"/>
								<h:inputText value="#{postoBean.posto.noPosto}" id="noPosto" 
								required="true" styleClass="upper" maxlength="60" size="40" label="#{res.nome_posto}"/>
								
								<h:outputLabel value="#{res.longitude_posto}"  for="nuLogintude"/>
								<h:inputText value="#{postoBean.posto.lon}" id="nuLogintude" 
								required="true" maxlength="10" size="10" label="#{res.longitude_posto}"/>
								
								<h:outputLabel value="#{res.latitude_posto}"  for="nuLatitude"/>
								<h:inputText value="#{postoBean.posto.lat}" id="nuLatitude" 
								required="true" maxlength="10" size="10" label="#{res.latitude_posto}"/>
								
								<h:outputLabel value="#{res.uf_posto}"  for="sgUf"/>
								<h:inputText value="#{postoBean.posto.uf}" id="sgUf" 
								required="true" styleClass="upper" maxlength="2" size="2" label="#{res.uf_posto}"/>
								
								<h:outputLabel value="#{res.cidade_posto}"  for="noCidade"/>
								<h:inputText value="#{postoBean.posto.cidade}" id="noCidade" 
								required="true" styleClass="upper" maxlength="60" size="40" label="#{res.cidade_posto}"/>
								
								<h:outputLabel value="#{res.bairro_posto}"  for="noBairro"/>
								<h:inputText value="#{postoBean.posto.bairro}" id="noBairro" 
								required="true" styleClass="upper" maxlength="60" size="40" label="#{res.bairro_posto}"/>
								
								<h:outputLabel value="#{res.ddd_posto}"  for="ddd"/>
								<h:inputText value="#{postoBean.posto.ddd}" id="ddd" 
								required="true" styleClass="upper" maxlength="2" size="2" label="#{res.ddd_posto}"/>
								
								<h:outputLabel value="#{res.telefone_posto}"  for="telefone"/>
								<h:inputText value="#{postoBean.posto.telefone}" id="telefone" 
								required="true" styleClass="upper" maxlength="15" size="12" label="#{res.ddd_posto}"/>
								
								<h:outputLabel value="#{res.email_posto}"  for="email"/>
								<h:inputText value="#{postoBean.posto.email}" id="email" 
								required="true" styleClass="upper" maxlength="60" size="40" label="#{res.email_posto}"/>
								
							</h:panelGrid>
							
							<br />
							
							<h:panelGrid columns="4">
							
							<h:outputLabel value="#{res.combustivel}"  for="noCombustivel"/>
								<h:selectOneMenu value="#{postoBean.idCombustivel}" id="noCombustivel" label="#{res.combustivel}">
									<f:selectItem itemLabel="Selecione" itemValue="0"/>
									<f:selectItems value="#{postoBean.combustiveis}" />
								</h:selectOneMenu>
								
								<h:inputText value="#{postoBean.postoCombustivel.preco}" id="preco" size="10" />
								
								<a4j:commandLink action="#{postoBean.adicionarCombustivel}" value="X" render="tabelaPreco"/>
								
							</h:panelGrid>
							
							<br />
							
							<rich:dataTable value="#{postoBean.posto.postoCombustivels}" var="pc" id="tabelaPreco">
							
								<rich:column>
									<f:facet name="header">
										<h:outputText value="#{res.combustivel_Nome}" />
									</f:facet>
									<h:outputText value="#{pc.combustivel.noCombustivel}" />
								</rich:column>
							
								<rich:column>
									<f:facet name="header">
										<h:outputText value="#{res.preco}" />
									</f:facet>
									<h:outputText value="#{pc.preco}" />
								</rich:column>
								
								<rich:column style="text-align:center">
									<f:facet name="header">
										<h:outputText value="#{res.remover}" />
									</f:facet>
									<a4j:commandLink action="#{postoBean.removerCombustivel}" value="X" render="tabelaPreco">
										<f:setPropertyActionListener target="#{postoBean.postoCombustivel}" value="#{pc}" />
									</a4j:commandLink>
								</rich:column>
								
							</rich:dataTable>
							
							<br />
							
							<h:panelGrid columns="4">
							
							<h:outputLabel value="#{res.servico_nome}"  for="noServico"/>
								<h:selectOneMenu value="#{postoBean.idServico}" id="noServico" label="#{res.servico_nome}">
									<f:selectItem itemLabel="Selecione" itemValue="0"/>
									<f:selectItems value="#{postoBean.servicos}" />
								</h:selectOneMenu>
								
								<a4j:commandLink action="#{postoBean.adicionarServico}" value="X" render="tabelaServico"/>
								
							</h:panelGrid>
							
							<br />
							
							<rich:dataTable value="#{postoBean.posto.servicos}" var="ser" id="tabelaServico">
							
								<rich:column>
									<f:facet name="header">
										<h:outputText value="#{res.servico_nome}" />
									</f:facet>
									<h:outputText value="#{ser.noServico}" />
								</rich:column>
							
								<rich:column style="text-align:center">
									<f:facet name="header">
										<h:outputText value="#{res.remover}" />
									</f:facet>
									<a4j:commandLink action="#{postoBean.removerServico}" value="X" render="tabelaServico">
										<f:setPropertyActionListener target="#{postoBean.servico}" value="#{ser}" />
									</a4j:commandLink>
								</rich:column>
								
							</rich:dataTable>
							
							<br />
							<br />
							
							<h:commandButton action="#{postoBean.save}" value="Gravar" />
									
						</h:form>
					</rich:panel>
				</ui:define>
			</ui:composition>
		</h:body>
	</f:view>
</ui:composition>